<?php
namespace Home\Controller;

class GoodsController extends CommonController{

	public function index(){
		$where = array();
		$where['status'] = '1';
		$where['delete_status'] = '1';
		$where['type'] = I('type') ? I('type') : 1;
		$order = 'create_time desc';
		$page = I('page')?(int)I('page'):1;
		$this->assign('list',D(CONTROLLER_NAME)->where($where)->order($order)->page($page,5)->select());
		$this->assign('type',$where['type']);
		if(IS_POST){
			$this->list || $this->error('');
			$this->display('goods_list');
		}else{
			$this->display();
		}
	}
	
	public function detail(){
		I('get.id') && $data = D('Goods')->relation(true)->where(array('id'=>(int)I('get.id'),'delete_status'=>'1','status'=>'1'))->find();
		$data || $this->error('不存在此物品',U('index'));
		$this->assign('data',output_data($data));
		$this->assign('vip_status',D('Other')->getField('vip_status'));
		$this->assign('per_status',D('Other')->getField('per_status'));
		$this->display();
	}
	
}